<style>
<!--

.resQuery span.error {
    position: absolute !important;
    left: 260px;
}
-->
</style>
<link href="${rc.getContextPath()}/manage/css/dwzCustomCss/dwz.custom.css?v=${ver}" rel="stylesheet" type="text/css">
<form method="post" action="${rc.getContextPath()}/manage/material/saveMaterial" class=" pageForm required-validate" onsubmit="return materialAddOper.tsubmit(this);">
    <div class="pageContent">
        <div class="pageFormContent">
            <fieldset>
                <input type="hidden" name="navTabId" value="${navTabId!''}"> 
                <input type="hidden" name="id" value="<#if (material.materialCode)??>${material.materialText!''}</#if>"> 
                <input type="hidden" id="process" name="process" value="${process!''}">
                <dl>
            
                        <dt><@label key="materialCode.C,colon">物料编号：</@label></dt> <dd><input  class="required  alphanumeric toUp" name="materialCode" value="<#if (material.materialCode)??>${material.materialCode!''}</#if>"  type="text" maxlength="20"<#if (material.materialCode)??> readonly="readonly"<#else> remote="${rc.getContextPath()}/manage/material/validateMaterialCode"</#if> warn="<@label key="materialCodeExist.M">物料编号已经存在</@label>"/> </dd>
                </dl>
                <dl>
                        <dt><@label key="materialText.C,colon">物料描述：</@label></dt> <dd><input class="required"  name="materialText" value="<#if (material.materialText)??>${material.materialText!''}</#if>" type="text" maxlength="60" />  </dd>
                        </dl>
                <dl>
                        <dt><@label key="materialType.C,colon">物料类型：</@label></dt>
                         <dd><select name="materialTypeCode"> <#list materialTypes as type>
                            <option value="${type.materialTypeCode}"<#if material.materialTypeCode?? && material.materialTypeCode == type.materialTypeCode> selected="selected"</#if>>${type.materialTypeCode}-${type.typeText}</option> </#list>
                        </select></dd>
                    </dl>
                    <dl>
                        <dt><@label key="defaultWorkCenter.C,colon">默认工作中心：</@label></dt> 
                        <dd><select style="width:147px;" name="workCenterCode">
                            <option value=""></option>
                            <#if workCenters??><#if workCenters?size>0><#list workCenters as workCenter>
                            <option value="${workCenter.workCenterCode!''}"
                                 <#if  (material.materialCode)?? && material.workCenterCode??&& material.workCenterCode==workCenter.workCenterCode> selected="selected" 
                                 </#if>
                                 >${workCenter.workCenterCode!''}-${workCenter.workCenterText!''}</option>
                            </#list></#if></#if>
                        </select></dd></dl>
                    <dl>
            <dt><@label key="bomCode.C,colon">物料清单编号：</@label></dt>
            <dd class="resQuery">
                <input class="look" id="bomLookup.bomCode" name="bomCode" value="<#if (material.bomCode)??>${material.bomCode!''}</#if>" type="text" postField="bomCode" suggestFields="bomCode,bomText" 
                suggestUrl="${rc.getContextPath()}/manage/bom/bomSuggest" lookupGroup="bomLookup" 
                 warn="<@label key='bomCode.C,doesNotExist.C'>物料清单编号不存在</@label>"  remote="${rc.getContextPath()}/manage/bom/validateBomCodeForSelect"/>
                <a class="btnLook" width="700" height="450"  href="${rc.getContextPath()}/manage/bom/bomLookUp" rel="bomLookup_dialog" title="<@label key='select.C,bomCode.C'>选择物料清单</@label>"  lookupGroup="bomLookup"></a>
            </dd>
        </dl>
        <dl>
            <dt><@label key="bomText.C,colon">物料清单描述：</@label></dt>
            <dd ><input id="bomLookup.bomText" name="bomText" type="text" readonly="readonly" value="<#if (material.bomText)??>${material.bomText!''}</#if>"/></dd>
        </dl>
        <dl>
        	<dt><@label key="makelotsize.C,colon">生产批量：</@label></dt> 
        	<dd><input name="makelotsize" class="digits" maxlength="10" min="1" value="<#if (material.makelotsize)??>${material.makelotsize!''}</#if>" type="text" maxlength="60" />  </dd>
        </dl>
        <dl>
        	<dt><@label key="materialspec.C,colon">物料规格：</@label></dt> 
        	<dd><input name="materialspec" value="<#if (material.materialspec)??>${material.materialspec!''}</#if>" type="text" maxlength="60" />  </dd>
        </dl>
        <dl>
        	<dt><@label key="LeadTime.C">提前期：</@label>(<@label key="day.C">日</@label>)<@label key="colon">:</@label></dt> 
        	<dd><input class="digits" name="materialLeadTimeNum" value="<#if (material.materialLeadTimeNum)??>${material.materialLeadTimeNum!''}</#if>" type="text" maxlength="6" min="1" />  </dd>
        </dl>
        <dl class="nowrap">
        <dt>&nbsp;</dt>
        <dd>
            <label style="width: 80px;"><input type="checkbox" name="makeFlag" value="1"<#if (material.makeFlag)?? && (material.makeFlag == 1)> checked="true"</#if>><@label key="makeFlag.C">自制件</@label></label>
            <label style="width: 80px;"><input type="checkbox" name="buyFlag" value="1"<#if (material.buyFlag)?? && (material.buyFlag == 1)> checked="true"</#if>><@label key="buyFlag.C">采购件</@label></label>
        </dd>
        <dd>
            <label style="width: 80px;"><input type="checkbox" name="operationScheduleFlag" value="1"<#if (material.operationScheduleFlag)?? && (material.operationScheduleFlag == 1)> checked="true"</#if>><@label key="operationScheduleFlag.C">工序派工</@label></label>
        </dd>
        </dl>
                <dl class="nowrap">
                    <dd>
                       
                        <div  class="panel"  currentIndex="0" eventType="click" style="width: 605px;margin: 0;">
                        <h1><@label key="process.C">工艺路线</@label></h1>
                        <div>
                        <div id="bar" class="pBar">
                                        <ul class="toolBar">
                                            <input id="processid" type="hidden" name="processLookup.id" type="text" />
                                            <input id="processname" type="hidden" name="processLookup.name" type="text" />
                                            <li><a class="add" width="660" height="510" href="${rc.getContextPath()}/manage/material/selectProcess?navTabId=${navTabId!''}" lookupGroup="processLookup" callback="materialAddOper.process_callback" ><span><@label key="add.B">新增</@label></span> </a></li>
                                            <li><a href="javascript:" class="delete" onclick="materialAddOper.processdel()"><span><@label key="delete.B">删除</@label></span> </a></li>
                                        </ul>
                                    </div>
                                    <table class="table border" width="100%" <#if (material.materialCode)??>layoutH="420"<#else>layoutH="350"</#if>>
                                        <thead>
                                            <tr>
                                                <th width="20"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
                                                <th width="100"><@label key="cmprocess_code.C">工艺编号</@label></th>
                                                <th width="100"><@label key="cmprocess_name.C">工艺名称</@label></th>
                                                <th width="100"><@label key="defaultProcess.C">默认工艺</@label></th>
                                            </tr>
                                        </thead>
                                        <tbody id="processtbody">
                                            <#if processes??><#if (processes?size>0)> <#list processes as process>
                                            <tr id="process_${process.processCode!''}" target="process_code" rel="${process.processCode!''}">
                                                <td width="16"><input type="checkbox" name="ids" class="checkboxCtrl" value="${process.processCode!''}"></td>
                                                <td width="100">${process.processCode!''}</td>
                                                <td width="100">${process.processText!''}</td>
                                                <td width="100">
                                                <input type="radio" name="processCode" value="${process.processCode!''}"                                            
                                                <#if material.processCode?? && material.processCode == process.processCode> checked</#if>/>
                                                </td>
                                            </tr>
                                            </#list> </#if> </#if>
                                        </tbody>
                                    </table>
                                    </div>
                        </div>
                    </dd>
                </dl>
            </fieldset>
        </div>
                <#if (material.materialCode)??> 
            <#assign createInfo=material/>
            <#include "/common/createInfo.html">
        </#if>
        <div class="formBar">
            <ul>
                <li><div class="buttonActive" id="save">
                        <div class="buttonContent">
                            <button type="submit"><@label key="save.B">保存</@label></button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="buttonActiveGrey">
                        <div class="buttonContent">
                            <button type="button" class="close"><@label key="cancel.B">取消</@label></button>
                        </div>
                    </div></li>
            </ul>
        </div>
    </div>
    <#macro bpTree children> <#if children?? && children?size gt 0> <#list children as child>
    <li><a tvalue="${child.menuCode}" tname="${child.menuText}"<#if (child.isChecked)?? && (child.isChecked == 1)> checked="true"</#if>>${child.menuText}</a> <#if child.children?? &&child.children?size gt 0>
        <ul><@bpTree children=child.children />
        </ul> </#if> </#list> </#if> </#macro>
</form>



<script type="text/javascript">
var materialAddOper={
	//记录当前页面对象信息
	_page : DWZ.context(),
	process_callback : function(){
	    var id = $("#processid",materialAddOper._page).val();
	    var name = $("#processname",materialAddOper._page).val();
	    var idArr = new Array();
	    var nameArr = new Array();
	    idArr = id.split(',');
	    nameArr = name.split(',');
	    var ht = "";
	    for ( var i = 0; i < idArr.length; i++) {
	        var processid = idArr[i];
	        var processname = nameArr[i];
	        var my_element = $("#process_" + processid,materialAddOper._page);
	        if (my_element.length == 0) {
	            ht += "<tr id='process_"+processid+"'target='process_code' rel='"+processid+"'><td width='16'><input  name='ids' value='"+processid+"' type='checkbox'></td><td width='100'>"
	                    + processid
	                    + "</td><td width='100'>"
	                    + processname
	                    + "</td><td width='100'>"
	                    + "<input type='radio' name='processCode' value='"+processid+"'<#if material.processCode?? && material.processCode == process.processCode> checked</#if>/>"
	                    + "</td></tr>";
	        }

	    }
	    $("#processtbody",materialAddOper._page).append(ht);
	},
	processdel : function() {
	    var count = 0;
	    $('input[name="ids"]:checked',materialAddOper._page).each(function(i, e) {
	        count++;
	    });
	    if (count == 0) {
	        alertMsg.warn('<@label key="selectProcess.M">请选择工艺！</@label>')
	    } else {
	        alertMsg.confirm("<@label key="delProcess.M">确定要删除选中的工艺吗？</@label>", {
	            okCall : function() {
	                $('input[name="ids"]:checked',materialAddOper._page).each(function(i, e) {
	                    $("#process_" + e.value,materialAddOper._page).remove();
	                });
	            }
	        });
	    }
	},
	tsubmit : function(t)
	{
	    var process = "";

	    var processtable = $("#processtbody",materialAddOper._page);
	    processtable.find("tr").each(function(i, n) {
	        var obj = $(n)
	        process += obj.attr("id").replace("process_", "") + ",";
	    });
	     
	    if (process.length > 1) {
	        process = process.substring(0, process.length - 1);
	    }
	    $("#process",materialAddOper._page).val(process);
	    if(process!="")
	    {
		    var processCode= $("input[name='processCode']:checked",materialAddOper._page).val();
		    if(typeof(processCode)=="undefined")
		    {
		          alertMsg.warn('<@label key="selectDefaultProcess.M">请选中一个默认的工艺路线！</@label>')
		          return false;
		    }
	    }
	    
	    return validateCallback(t, dialogAjaxDone);
	}
}

</script>
